// components/player/player.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    playerList:{
      type:Object,
      value:{}
    }
  },

  /* 数据监听 */
  observers:{
    'playerList':function(newV){
      //console.log(this.properties.playerList);
      if(newV.newsList==null || newV.length=='0') return;
      let list = newV.newsList;
      this.data.leftList = [];
      this.data.rightList = [];
      list.splice(0,1);
      list.forEach((i,index)=>{
        index % 2 ? this.data.leftList.push(i) : this.data.rightList.push(i)
      })
      //console.log(list);
      this.setData({
        leftList:this.data.leftList,
        rightList:this.data.rightList
      })
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    leftList:[],
    rightList:[]
  },

  lifetimes:{
    attached:function(){
      // 在组件实例进入页面节点树时执行
      this.setData({
        scale:app.globalData.scale
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //点击打开详情页
    onClickOutLink(e){
      //console.log(e);
      if( app.openLoginPage() ) return;
      app.toOutLink(e);
    },

    //点击跳转导航
    onClickLocation(e){
      //console.log(e);
      app.onClickLocation(e.currentTarget.dataset.locationName,e.currentTarget.dataset.location);
    }
  }
})
